@tool
class_name ControllerCommand_CallMethod
extends ControllerCommand

## 执行方法

#region 属性
@export var node_path:NodePath
@export var method_name:String
@export var method_args:Dictionary[String,Variant]
@export var cancel_method_name:String
@export var cancel_method_args:Dictionary[String,Variant]
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func activate(controller:ControllerComponent,command_dict_by_tag:Dictionary) -> bool:
	if not super(controller,command_dict_by_tag):
		return false
	var node = controller.get_node(node_path)
	if not node:
		return false
	if not method_name or not node.has_method(method_name):
		return false
	node[method_name].callv(method_args.values())
	return true
func deactivate(controller:ControllerComponent,command_dict_by_tag:Dictionary):
	var node = controller.get_node(node_path)
	if not node:
		return false
	if not method_name or not node.has_method(cancel_method_name):
		return false
	node[cancel_method_name].callv(cancel_method_args.values())
	super(controller,command_dict_by_tag)
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
#endregion
